<?php

// +----------------------------------------------------------------------

// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]

// +----------------------------------------------------------------------

// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.

// +----------------------------------------------------------------------

// | Author: Dean <zxxjjforever@163.com>

// +----------------------------------------------------------------------

namespace plugins\goods\model;//Demo插件英文名，改成你的插件英文就行了

use think\Model;



//Demo插件英文名，改成你的插件英文就行了,插件数据表最好加个plugin前缀再加表名,这个类就是对应“表前缀+plugin_demo”表

class GoodsFreightModel extends Model

{

    /**

     * 默认运费计算

     */

    function getPrice($freight,$goods_num,$freight_price){

        

        $cut_price = $goods_num-$freight['default_num'];//超首件数

        if($cut_price<$freight['continue_num']){//未超出续件数

            $freight_price = $freight['default_price'];//最后价格

        }elseif ($cut_price >= $freight['continue_num']){//超续件数 

            $freight_prices = $freight['continue_price'] * floor($cut_price/$freight['continue_num']) + $freight['default_price'];//运费= 续费*(超首件数/续件数)+首费

            if($freight_prices>$freight_price) $freight_price = $freight_prices;

        }

        if($freight['type'] == 1){//包邮

            if($goods_num >= $freight['free_shipping']){

                $freight_price = 0;

            }
        }

        return $freight_price;

    }









}